const path = require("path");
const judgeMobile = (req, res) => {
    //(req, res, next)
    return (req, res, next) => {
        const deviceAgent = req.headers["user-agent"] || "iphone";
        const tocaseWord = deviceAgent.toLowerCase()
        const agentID = tocaseWord.match(/(iphone|ipod|ipad|android)/);
        // console.log("deviceAgent", deviceAgent);
        if (agentID) {
            //移动端提示页面
            //   var msg = "移动端";
            //   console.log("agentID：", agentID);
            //   return msg;
            res.sendFile(path.join(process.cwd(), "dist/views", "stopIphone.html"));
        } else {
            //   var msg2 = "电脑端";
            //   return msg2;
            next();
        }
    };
};

module.exports = judgeMobile;